package com.ikun.admin.modules.sys.controller;

import com.ikun.admin.common.annotation.OperationAnno;
import com.ikun.admin.modules.sys.entity.Dict;
import com.ikun.admin.modules.sys.entity.Notice;
import com.ikun.admin.modules.sys.entity.User;
import com.ikun.admin.modules.sys.iservice.IDictAndNoticeService;
import com.ikun.admin.modules.sys.vo.*;
import com.ikun.common.result.Result;
import com.ikun.common.search.PageData;
import com.ikun.common.search.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.PathProvider;

import java.util.List;
import java.util.Set;

/**
 * @ClassName DictAndNoticeController
 * @Description:
 * @CreateDate: 2024/7/17 9:26
 */
@Api(tags = "系统公告和字典")
@RestController
@RequestMapping("/sys/dictAndNotice")
public class DictAndNoticeController {

    @Autowired
    private IDictAndNoticeService iDictAndNoticeService;
    @Autowired
    private PathProvider pathProvider;

    @PostMapping("/notice/list/API_001")
    @ApiOperation("/系统公告分页接口")
    public Result<PageResult<NoticeListResultVo>> noticeList(@RequestBody PageData<NoticeListParamVo> pageData) {
        return iDictAndNoticeService.noticeList(pageData);
    }

    @GetMapping("/notice/select/API_002/{id}")
    @ApiOperation("根据id查询公告详情")
    public Result<NoticeDetailVo> noticeDetail(@PathVariable Long id) {
        return iDictAndNoticeService.noticeDetail(id);
    }

    @PostMapping("/notice/addOrUpdate/API_003")
    @ApiOperation("新增或修改公告")
    @OperationAnno(type = 0, tableEntity = Notice.class)
    public Result<String> addOrUpdateNotice(@RequestBody NoticeAddOrUpdateVo noticeAddOrUpdateVo) {
        return iDictAndNoticeService.addOrUpdateNotice(noticeAddOrUpdateVo);
    }

    @DeleteMapping("/notice/delete/API_004/{id}")
    @ApiOperation("删除公告")
    @OperationAnno(type = 1, tableEntity = Notice.class)
    public Result<String> deleteNotice(@PathVariable Long id) {
        return iDictAndNoticeService.deleteNotice(id);
    }

    @PostMapping("/dict/list/API_005")
    @ApiOperation("系统字典分页接口")
    public Result<PageResult<DictCommonResultVo>> dictList(@RequestBody PageData<DictListParamVo> pageData) {
        return iDictAndNoticeService.dictList(pageData);
    }

    @GetMapping("/dict/select/API_006/{id}")
    @ApiOperation("查询字典详情")
    public Result<DictCommonResultVo> dictDetail(@PathVariable Long id) {
        return iDictAndNoticeService.dictDetail(id);
    }

    @PostMapping("/dict/addOrUpdate/API_007")
    @ApiOperation("新增或者修改字典")
    @OperationAnno(type=0,tableEntity = Dict.class)
    public Result<String> addOrUpdateDict(@RequestBody DictCommonResultVo dictAddOrUpdateVo) {
        return iDictAndNoticeService.addOrUpdateDict(dictAddOrUpdateVo);
    }

    @DeleteMapping("/dict/delete/API_008/{id}")
    @ApiOperation("删除字典")
    @OperationAnno(type=1,tableEntity = Dict.class)
    public Result<String> deleteDict(@PathVariable Long id) {
        return iDictAndNoticeService.deleteDict(id);
    }

    @GetMapping("/dict/dict/API_009/{cluster}")
    @ApiOperation("根据分组查询字典")
    public Result<List<DictCommonResultVo>> selectDictByGroup(@PathVariable String cluster) {
        return iDictAndNoticeService.selectDictByGroup(cluster);
    }

    @GetMapping("/dict/select/API_010")
    @ApiOperation("查询字典所有的分组类别")
    public Result<Set<String>> selectClusterList() {
        return iDictAndNoticeService.selectClusterList();
    }

    @PostMapping("/notice/update/API_011/{id}")
    @ApiOperation("撤销公告")
    @OperationAnno(type=0,tableEntity = Dict.class)
    public Result<String> updateNoticeStatus(@PathVariable Long id) {
        return iDictAndNoticeService.updateNoticeStatus(id);
    }
}
